using System;

namespace TimerUppercut.Domain
{
    public interface ITimer
    {
        Guid Id { get; set; }
        ulong Hours { get; set; }
        int Minutes { get; set; }
        int Seconds { get; set; }
        string Description { get; set; }
        ulong TotalSeconds { get; set; }
    }

    /// <summary>
    /// A schedule entry.
    /// </summary>
    public class Timer : ITimer
    {
        private ulong _totalSeconds;

        public Guid Id { get; set; }
        public ulong Hours { get; set; }
        public int Minutes { get; set; }
        public int Seconds { get; set; }
        public string Description { get; set; }
        public ulong TotalSeconds
        {
            get
            {
                if(_totalSeconds==0) TotalSeconds = new ulong();
                return _totalSeconds;
            }
            set
            {
                var hours = Hours * 3600;
                var minutes = Minutes * 60;
                _totalSeconds = (hours + (ulong) minutes + (ulong) Seconds);
            }
        }

        public override string ToString() 
        {
            return string.Format("{0}.{1}.{2}", Hours, Minutes, Seconds); 
        }
    }
}